package com.fjl.gson.test;

import org.json.JSONArray;
import org.json.JSONException;



public class JsonToStr
{

	public static void main(String[] args)
	{
		readStr2();
	}
	
	private static void readStr()
	{
		String jsonArr = "{\"TotalCount\":2,\"AttStruct\":{\"FldName\":[\"ID\",\"mpLength\",\"ROUTECODE\",\"GEOPOINT\",\"SUBPOINT\",\"R_CODE\",\"RIGHT_BODY\",\"LEFT_BODY\",\"TYPE\",\"TREND\",\"DIP\",\"DIP_ANG\",\"RELATION\",\"GBCODE\",\"REMARK\",\"DATE0\",\"MAPCODE\",\"ORDER0\",\"PRIGHT_BODY\",\"PLEFT_BODY\",\"PTYPE\",\"PRELATION\",\"CODE1\",\"CODE2\",\"mpLayer\"],\"FldType\":[\"long\",\"double\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"long\",\"long\",\"long\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"long\"],\"FldNumber\":25},\"SFEleArray\":[{\"bound\":{\"xmin\":7234.875866402922,\"ymin\":86443.41022057706,\"xmax\":7243.251730163737,\"ymax\":86447.83117805068},\"fGeom\":{\"PntGeom\":[],\"RegGeom\":[],\"LinGeom\":[{\"Line\":{\"temp\":0,\"Arcs\":[{\"Dots\":[{\"x\":7236.478331403684,\"y\":86447.83117805068},{\"x\":7235.807877177279,\"y\":86447.23243454317},{\"x\":7235.515445389603,\"y\":86446.76103450144},{\"x\":7234.875866402922,\"y\":86445.76662658145}],\"ArcID\":0}]},\"GID\":0}]},\"ftype\":2,\"GraphicInfo\":null,\"FID\":1,\"AttValue\":[\"1\",\"2.635959531894713\",\"L6001\",\"D0003\",\"0\",\"1\",\"Jxzh\",\"Jxzh\",\"岩相界线\",\"0\",\"0\",\"0\",\"整合关系\",\"\",\"\",\"20160725220301\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"0\"]},{\"bound\":{\"xmin\":7234.875866402922,\"ymin\":86443.41022057706,\"xmax\":7243.251730163737,\"ymax\":86447.83117805068},\"fGeom\":{\"PntGeom\":[],\"RegGeom\":[],\"LinGeom\":[{\"Line\":{\"temp\":0,\"Arcs\":[{\"Dots\":[{\"x\":7242.298654565293,\"y\":86443.41022057706},{\"x\":7243.251730163737,\"y\":86445.0507605416}],\"ArcID\":0}]},\"GID\":0}]},\"ftype\":2,\"GraphicInfo\":null,\"FID\":2,\"AttValue\":[\"2\",\"1.8972939866077108\",\"L6001\",\"DG002\",\"0\",\"1\",\"（Qp3-Qh）pal＋eol\",\"Jxzh\",\"岩相界线\",\"0\",\"0\",\"0\",\"整合\",\"\",\"\",\"20160725211406\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"0\"]}]}";
		
			System.out.println(jsonArr);
//			JSONObject ob = new JSONObject(jsonArr);
//			JSONArray jsonOb = ob.getJSONArray("FldName");
//			System.out.println(jsonOb);
	}
	
	private static void readStr2()
	{
//		String jsonArr = "{[{ y: 55.11, color : colors[0] },{ y: 21.63, color: colors[1] },{ y: 11.94,color: colors[2] },{ y: 117.15, color: colors[3]}]}";
		String jsonArr = "{\"TotalCount\":2,\"AttStruct\":{\"FldName\":[\"ID\",\"mpLength\",\"ROUTECODE\",\"GEOPOINT\",\"SUBPOINT\",\"R_CODE\",\"RIGHT_BODY\",\"LEFT_BODY\",\"TYPE\",\"TREND\",\"DIP\",\"DIP_ANG\",\"RELATION\",\"GBCODE\",\"REMARK\",\"DATE0\",\"MAPCODE\",\"ORDER0\",\"PRIGHT_BODY\",\"PLEFT_BODY\",\"PTYPE\",\"PRELATION\",\"CODE1\",\"CODE2\",\"mpLayer\"],\"FldType\":[\"long\",\"double\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"long\",\"long\",\"long\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"string\",\"long\"],\"FldNumber\":25},\"SFEleArray\":[{\"bound\":{\"xmin\":7234.875866402922,\"ymin\":86443.41022057706,\"xmax\":7243.251730163737,\"ymax\":86447.83117805068},\"fGeom\":{\"PntGeom\":[],\"RegGeom\":[],\"LinGeom\":[{\"Line\":{\"temp\":0,\"Arcs\":[{\"Dots\":[{\"x\":7236.478331403684,\"y\":86447.83117805068},{\"x\":7235.807877177279,\"y\":86447.23243454317},{\"x\":7235.515445389603,\"y\":86446.76103450144},{\"x\":7234.875866402922,\"y\":86445.76662658145}],\"ArcID\":0}]},\"GID\":0}]},\"ftype\":2,\"GraphicInfo\":null,\"FID\":1,\"AttValue\":[\"1\",\"2.635959531894713\",\"L6001\",\"D0003\",\"0\",\"1\",\"Jxzh\",\"Jxzh\",\"岩相界线\",\"0\",\"0\",\"0\",\"整合关系\",\"\",\"\",\"20160725220301\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"0\"]},{\"bound\":{\"xmin\":7234.875866402922,\"ymin\":86443.41022057706,\"xmax\":7243.251730163737,\"ymax\":86447.83117805068},\"fGeom\":{\"PntGeom\":[],\"RegGeom\":[],\"LinGeom\":[{\"Line\":{\"temp\":0,\"Arcs\":[{\"Dots\":[{\"x\":7242.298654565293,\"y\":86443.41022057706},{\"x\":7243.251730163737,\"y\":86445.0507605416}],\"ArcID\":0}]},\"GID\":0}]},\"ftype\":2,\"GraphicInfo\":null,\"FID\":2,\"AttValue\":[\"2\",\"1.8972939866077108\",\"L6001\",\"DG002\",\"0\",\"1\",\"（Qp3-Qh）pal＋eol\",\"Jxzh\",\"岩相界线\",\"0\",\"0\",\"0\",\"整合\",\"\",\"\",\"20160725211406\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"0\"]}]}";
		//JSONArray
		String jsonMessage = "[{'num':'成绩', '外语':88, '历史':65, '地理':99, 'object':{'aaa':'1111','bbb':'2222','cccc':'3333'}}," +
		           "{'num':'兴趣', '外语':28, '历史':45, '地理':19, 'object':{'aaa':'11a11','bbb':'2222','cccc':'3333'}}," +
		           "{'num':'爱好', '外语':48, '历史':62, '地理':39, 'object':{'aaa':'11c11','bbb':'2222','cccc':'3333'}}]";
		System.out.println(jsonArr);
			
			try
			{
				org.json.JSONObject ob = new org.json.JSONObject(jsonArr);
				System.out.println(ob.toString());
				
				//有问题
//				org.json.JSONArray jsonOb = ob.getJSONArray("FldType");
//				System.out.println(jsonOb.toString());
				 
				JSONArray myJsonArray = new JSONArray(jsonMessage);
				System.out.println(myJsonArray.toString());
			}
			catch (JSONException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
	}
}
